# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=openscad
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2015.03
pkgrel=2
pkgdesc="The programmers solid 3D CAD modeller (mingw-w64)"
arch=('any')
license=("GPL2")
url="http://openscad.org/"
depends=("${MINGW_PACKAGE_PREFIX}-qt5"
         "${MINGW_PACKAGE_PREFIX}-boost"
         "${MINGW_PACKAGE_PREFIX}-cgal"
         "${MINGW_PACKAGE_PREFIX}-opencsg"
         "${MINGW_PACKAGE_PREFIX}-qscintilla"
         "${MINGW_PACKAGE_PREFIX}-shared-mime-info")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-eigen3"
             "${MINGW_PACKAGE_PREFIX}-imagemagick")
options=(!strip staticlibs !buildflags)
source=("http://files.openscad.org/${_realname}-${pkgver}.src.tar.gz")
sha256sums=('68ce08adc9e90c606ad948fe0f3405ce62b03b6bf34c45dd3dfc6b20c1846182')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  rm -f libraries/MCAD/*.py
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}
  BOOSTDIR=${MINGW_PREFIX} \
  CGALDIR=${MINGW_PREFIX} \
  EIGENDIR=${MINGW_PREFIX} \
  GLEWDIR=${MINGW_PREFIX} \
  OPENCSGDIR=${MINGW_PREFIX} \
  ${MINGW_PREFIX}/bin/qmake CONFIG+=release PREFIX="${pkgdir}${MINGW_PREFIX}" VERSION="${pkgver}"

  make -j1
  convert "icons/${_realname}.png" -resize 128x128\> "icons/${_realname}-128.png"
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}
  make INSTALL_ROOT= install
  install -Dm644 "icons/${_realname}.xml" "${pkgdir}${MINGW_PREFIX}/share/mime/packages/${_realname}.xml"
}
